package com.example.administrator.trains;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import java.io.IOException;

public class change_ticket extends Activity {

    String vehicleNum;
    String startPlace;
    String endPlace;
    String startTime;
    String endTime;
    String date;
    String id;
    String train_type;
    String ticket_type = null;
    String type1_num;
    String type2_num;
    String type3_num;
    String type4_num;
    String type1_price;
    String type2_price;
    String type3_price;
    String type4_price;
    String old_vehicleNum;
    String price;
    String type_num;

    Handler myHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if(msg.what==1){
                Toast.makeText(change_ticket.this,"改签成功,可以查看订单哦~~",Toast.LENGTH_LONG).show();
                Intent i = new Intent(change_ticket.this, select.class);
                i.putExtra("id", id);
                startActivity(i);
                change_ticket.this.finish();
            }
            if(msg.what==2){
                Toast.makeText(change_ticket.this,"改签失败",Toast.LENGTH_LONG).show();
            }
            if(msg.what==3){
                Toast.makeText(change_ticket.this,"亲,请选择座位类型",Toast.LENGTH_LONG).show();
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(getWindow().FEATURE_NO_TITLE);
        setContentView(R.layout.activity_order);

        Intent i = getIntent();
        id = i.getStringExtra("id");
        old_vehicleNum = i.getStringExtra("old_vehicleNum");
        vehicleNum = i.getStringExtra("vehicleNum");
        startPlace = i.getStringExtra("startPlace");
        endPlace = i.getStringExtra("endPlace");
        startTime = i.getStringExtra("startTime");
        endTime = i.getStringExtra("endTime");
        date = i.getStringExtra("date");
        train_type = i.getStringExtra("type").trim();
        type1_num = i.getStringExtra("type1_num");
        type2_num = i.getStringExtra("type2_num");
        type3_num = i.getStringExtra("type3_num");
        type4_num = i.getStringExtra("type4_num");
        type1_price = i.getStringExtra("type1_price");
        type2_price = i.getStringExtra("type2_price");
        type3_price = i.getStringExtra("type3_price");
        type4_price = i.getStringExtra("type4_price");

        final TextView czh_tv1 = (TextView)findViewById(R.id.from_station);  //开始地
        final TextView czh_tv4 = (TextView)findViewById(R.id.to_station);  //目的地
        final TextView czh_tv2 = (TextView)findViewById(R.id.start_time);   //开始时间
        final TextView czh_tv16 = (TextView)findViewById(R.id.end_time); //到达时间
        final TextView czh_tv14 = (TextView)findViewById(R.id.train_num);  //车次
        final TextView czh_tv13 = (TextView)findViewById(R.id.date);  //日期
        final TextView czh_tv12 = (TextView)findViewById(R.id.ticket_price);
        final TextView czh_tv15 = (TextView)findViewById(R.id.ticket_num);//票数

        //车票的类型
        final TextView text_erdengzhuo = (TextView) findViewById(R.id.erdengzhuo);
        final TextView text_yidengozhuo = (TextView) findViewById(R.id.yidengozhuo);
        final TextView text_tedengzhuo = (TextView) findViewById(R.id.tedengzhuo);
        final TextView text_wuzuo = (TextView) findViewById(R.id.wuzuo);
        final TextView text_yinzuo = (TextView) findViewById(R.id.yinzuo);
        final TextView text_ruanzuo = (TextView) findViewById(R.id.ruanzuo);
        final TextView text_yinwo = (TextView) findViewById(R.id.yinwo);
        final TextView text_ruanwo = (TextView) findViewById(R.id.ruanwo);
        final TextView text_gaojiruanwo = (TextView) findViewById(R.id.gaojiruanwo);
        final TextView text_dongwo = (TextView) findViewById(R.id.dongwo);

        //将点击到的颜色变深，没有点击到的变浅
        if (train_type.equals("G") == true) {
            text_erdengzhuo.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    text_erdengzhuo.setBackgroundResource(R.drawable.select);
                    text_yidengozhuo.setBackgroundResource(R.drawable.select1);
                    text_tedengzhuo.setBackgroundResource(R.drawable.select1);
                    text_wuzuo.setBackgroundResource(R.drawable.select1);
                    text_yinzuo.setBackgroundResource(R.drawable.select1);
                    text_ruanzuo.setBackgroundResource(R.drawable.select1);
                    text_yinwo.setBackgroundResource(R.drawable.select1);
                    text_ruanwo.setBackgroundResource(R.drawable.select1);
                    text_gaojiruanwo.setBackgroundResource(R.drawable.select1);
                    text_dongwo.setBackgroundResource(R.drawable.select1);
                    text_erdengzhuo.setTextColor(getResources().getColor(R.color.white));
                    text_yidengozhuo.setTextColor(getResources().getColor(R.color.black));
                    text_tedengzhuo.setTextColor(getResources().getColor(R.color.black));
                    text_wuzuo.setTextColor(getResources().getColor(R.color.black));
                    text_yinzuo.setTextColor(getResources().getColor(R.color.black));
                    text_ruanzuo.setTextColor(getResources().getColor(R.color.black));
                    text_yinwo.setTextColor(getResources().getColor(R.color.black));
                    text_ruanwo.setTextColor(getResources().getColor(R.color.black));
                    text_gaojiruanwo.setTextColor(getResources().getColor(R.color.black));
                    text_dongwo.setTextColor(getResources().getColor(R.color.black));
                    ticket_type = "二等座";
                    czh_tv12.setText((type1_price+"元").trim());
                    czh_tv15.setText((type1_num+"张").trim());
                    price = type1_price;
                    type_num = "1";
                }
            });
            text_yidengozhuo.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    text_erdengzhuo.setBackgroundResource(R.drawable.select1);
                    text_yidengozhuo.setBackgroundResource(R.drawable.select);
                    text_tedengzhuo.setBackgroundResource(R.drawable.select1);
                    text_wuzuo.setBackgroundResource(R.drawable.select1);
                    text_yinzuo.setBackgroundResource(R.drawable.select1);
                    text_ruanzuo.setBackgroundResource(R.drawable.select1);
                    text_yinwo.setBackgroundResource(R.drawable.select1);
                    text_ruanwo.setBackgroundResource(R.drawable.select1);
                    text_gaojiruanwo.setBackgroundResource(R.drawable.select1);
                    text_dongwo.setBackgroundResource(R.drawable.select1);
                    text_erdengzhuo.setTextColor(getResources().getColor(R.color.black));
                    text_yidengozhuo.setTextColor(getResources().getColor(R.color.white));
                    text_tedengzhuo.setTextColor(getResources().getColor(R.color.black));
                    text_wuzuo.setTextColor(getResources().getColor(R.color.black));
                    text_yinzuo.setTextColor(getResources().getColor(R.color.black));
                    text_ruanzuo.setTextColor(getResources().getColor(R.color.black));
                    text_yinwo.setTextColor(getResources().getColor(R.color.black));
                    text_ruanwo.setTextColor(getResources().getColor(R.color.black));
                    text_gaojiruanwo.setTextColor(getResources().getColor(R.color.black));
                    text_dongwo.setTextColor(getResources().getColor(R.color.black));
                    ticket_type = "一等座";
                    czh_tv12.setText((type2_price+"元").trim());
                    czh_tv15.setText((type2_num+"张").trim());
                    price = type2_price;
                    type_num = "2";
                }
            });
            text_tedengzhuo.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    text_erdengzhuo.setBackgroundResource(R.drawable.select1);
                    text_yidengozhuo.setBackgroundResource(R.drawable.select1);
                    text_tedengzhuo.setBackgroundResource(R.drawable.select);
                    text_wuzuo.setBackgroundResource(R.drawable.select1);
                    text_yinzuo.setBackgroundResource(R.drawable.select1);
                    text_ruanzuo.setBackgroundResource(R.drawable.select1);
                    text_yinwo.setBackgroundResource(R.drawable.select1);
                    text_ruanwo.setBackgroundResource(R.drawable.select1);
                    text_gaojiruanwo.setBackgroundResource(R.drawable.select1);
                    text_dongwo.setBackgroundResource(R.drawable.select1);
                    text_erdengzhuo.setTextColor(getResources().getColor(R.color.black));
                    text_yidengozhuo.setTextColor(getResources().getColor(R.color.black));
                    text_tedengzhuo.setTextColor(getResources().getColor(R.color.white));
                    text_wuzuo.setTextColor(getResources().getColor(R.color.black));
                    text_yinzuo.setTextColor(getResources().getColor(R.color.black));
                    text_ruanzuo.setTextColor(getResources().getColor(R.color.black));
                    text_yinwo.setTextColor(getResources().getColor(R.color.black));
                    text_ruanwo.setTextColor(getResources().getColor(R.color.black));
                    text_gaojiruanwo.setTextColor(getResources().getColor(R.color.black));
                    text_dongwo.setTextColor(getResources().getColor(R.color.black));
                    ticket_type = "特等座";
                    czh_tv12.setText((type3_price+"元").trim());
                    czh_tv15.setText((type3_num+"张").trim());
                    price = type3_price;
                    type_num = "3";
                }
            });
        } else if(train_type.equals("K") == true||
                train_type.equals("Z") == true ||
                train_type.equals("T") == true) {
            text_ruanwo.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    text_erdengzhuo.setBackgroundResource(R.drawable.select1);
                    text_yidengozhuo.setBackgroundResource(R.drawable.select1);
                    text_tedengzhuo.setBackgroundResource(R.drawable.select1);
                    text_wuzuo.setBackgroundResource(R.drawable.select1);
                    text_yinzuo.setBackgroundResource(R.drawable.select1);
                    text_ruanzuo.setBackgroundResource(R.drawable.select1);
                    text_yinwo.setBackgroundResource(R.drawable.select1);
                    text_ruanwo.setBackgroundResource(R.drawable.select);
                    text_gaojiruanwo.setBackgroundResource(R.drawable.select1);
                    text_dongwo.setBackgroundResource(R.drawable.select1);
                    text_erdengzhuo.setTextColor(getResources().getColor(R.color.black));
                    text_yidengozhuo.setTextColor(getResources().getColor(R.color.black));
                    text_tedengzhuo.setTextColor(getResources().getColor(R.color.black));
                    text_wuzuo.setTextColor(getResources().getColor(R.color.black));
                    text_yinzuo.setTextColor(getResources().getColor(R.color.black));
                    text_ruanzuo.setTextColor(getResources().getColor(R.color.black));
                    text_yinwo.setTextColor(getResources().getColor(R.color.black));
                    text_ruanwo.setTextColor(getResources().getColor(R.color.white));
                    text_gaojiruanwo.setTextColor(getResources().getColor(R.color.black));
                    text_dongwo.setTextColor(getResources().getColor(R.color.black));
                    ticket_type = "软卧";
                    czh_tv12.setText((type4_price+"元").trim());
                    czh_tv15.setText((type4_num+"张").trim());
                    price = type4_price;
                    type_num = "4";
                }
            });
            text_yinwo.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    text_erdengzhuo.setBackgroundResource(R.drawable.select1);
                    text_yidengozhuo.setBackgroundResource(R.drawable.select1);
                    text_tedengzhuo.setBackgroundResource(R.drawable.select1);
                    text_wuzuo.setBackgroundResource(R.drawable.select1);
                    text_yinzuo.setBackgroundResource(R.drawable.select1);
                    text_ruanzuo.setBackgroundResource(R.drawable.select1);
                    text_yinwo.setBackgroundResource(R.drawable.select);
                    text_ruanwo.setBackgroundResource(R.drawable.select1);
                    text_gaojiruanwo.setBackgroundResource(R.drawable.select1);
                    text_dongwo.setBackgroundResource(R.drawable.select1);
                    text_erdengzhuo.setTextColor(getResources().getColor(R.color.black));
                    text_yidengozhuo.setTextColor(getResources().getColor(R.color.black));
                    text_tedengzhuo.setTextColor(getResources().getColor(R.color.black));
                    text_wuzuo.setTextColor(getResources().getColor(R.color.black));
                    text_yinzuo.setTextColor(getResources().getColor(R.color.black));
                    text_ruanzuo.setTextColor(getResources().getColor(R.color.black));
                    text_yinwo.setTextColor(getResources().getColor(R.color.white));
                    text_ruanwo.setTextColor(getResources().getColor(R.color.black));
                    text_gaojiruanwo.setTextColor(getResources().getColor(R.color.black));
                    text_dongwo.setTextColor(getResources().getColor(R.color.black));
                    ticket_type = "硬卧";
                    czh_tv12.setText((type3_price+"元").trim());
                    czh_tv15.setText((type3_num+"张").trim());
                    price = type3_price;
                    type_num = "3";
                }
            });
            text_yinzuo.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    text_erdengzhuo.setBackgroundResource(R.drawable.select1);
                    text_yidengozhuo.setBackgroundResource(R.drawable.select1);
                    text_tedengzhuo.setBackgroundResource(R.drawable.select1);
                    text_wuzuo.setBackgroundResource(R.drawable.select1);
                    text_yinzuo.setBackgroundResource(R.drawable.select);
                    text_ruanzuo.setBackgroundResource(R.drawable.select1);
                    text_yinwo.setBackgroundResource(R.drawable.select1);
                    text_ruanwo.setBackgroundResource(R.drawable.select1);
                    text_gaojiruanwo.setBackgroundResource(R.drawable.select1);
                    text_dongwo.setBackgroundResource(R.drawable.select1);
                    text_erdengzhuo.setTextColor(getResources().getColor(R.color.black));
                    text_yidengozhuo.setTextColor(getResources().getColor(R.color.black));
                    text_tedengzhuo.setTextColor(getResources().getColor(R.color.black));
                    text_wuzuo.setTextColor(getResources().getColor(R.color.black));
                    text_yinzuo.setTextColor(getResources().getColor(R.color.white));
                    text_ruanzuo.setTextColor(getResources().getColor(R.color.black));
                    text_yinwo.setTextColor(getResources().getColor(R.color.black));
                    text_ruanwo.setTextColor(getResources().getColor(R.color.black));
                    text_gaojiruanwo.setTextColor(getResources().getColor(R.color.black));
                    text_dongwo.setTextColor(getResources().getColor(R.color.black));
                    ticket_type = "硬座";
                    czh_tv12.setText((type2_price+"元").trim());
                    czh_tv15.setText((type2_num+"张").trim());
                    price = type2_price;
                    type_num = "2";
                }
            });
            text_wuzuo.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    text_erdengzhuo.setBackgroundResource(R.drawable.select1);
                    text_yidengozhuo.setBackgroundResource(R.drawable.select1);
                    text_tedengzhuo.setBackgroundResource(R.drawable.select1);
                    text_wuzuo.setBackgroundResource(R.drawable.select);
                    text_yinzuo.setBackgroundResource(R.drawable.select1);
                    text_ruanzuo.setBackgroundResource(R.drawable.select1);
                    text_yinwo.setBackgroundResource(R.drawable.select1);
                    text_ruanwo.setBackgroundResource(R.drawable.select1);
                    text_gaojiruanwo.setBackgroundResource(R.drawable.select1);
                    text_dongwo.setBackgroundResource(R.drawable.select1);
                    text_erdengzhuo.setTextColor(getResources().getColor(R.color.black));
                    text_yidengozhuo.setTextColor(getResources().getColor(R.color.black));
                    text_tedengzhuo.setTextColor(getResources().getColor(R.color.black));
                    text_wuzuo.setTextColor(getResources().getColor(R.color.white));
                    text_yinzuo.setTextColor(getResources().getColor(R.color.black));
                    text_ruanzuo.setTextColor(getResources().getColor(R.color.black));
                    text_yinwo.setTextColor(getResources().getColor(R.color.black));
                    text_ruanwo.setTextColor(getResources().getColor(R.color.black));
                    text_gaojiruanwo.setTextColor(getResources().getColor(R.color.black));
                    text_dongwo.setTextColor(getResources().getColor(R.color.black));
                    ticket_type = "无座";
                    czh_tv12.setText((type1_price+"元").trim());
                    czh_tv15.setText((type1_num+"张").trim());
                    price = type1_price;
                    type_num = "1";
                }
            });
        } else if(train_type.equals("D") == true||
        train_type.equals("C") == true){
            text_yidengozhuo.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    text_erdengzhuo.setBackgroundResource(R.drawable.select1);
                    text_yidengozhuo.setBackgroundResource(R.drawable.select);
                    text_tedengzhuo.setBackgroundResource(R.drawable.select1);
                    text_wuzuo.setBackgroundResource(R.drawable.select1);
                    text_yinzuo.setBackgroundResource(R.drawable.select1);
                    text_ruanzuo.setBackgroundResource(R.drawable.select1);
                    text_yinwo.setBackgroundResource(R.drawable.select1);
                    text_ruanwo.setBackgroundResource(R.drawable.select1);
                    text_gaojiruanwo.setBackgroundResource(R.drawable.select1);
                    text_dongwo.setBackgroundResource(R.drawable.select1);
                    text_erdengzhuo.setTextColor(getResources().getColor(R.color.black));
                    text_yidengozhuo.setTextColor(getResources().getColor(R.color.white));
                    text_tedengzhuo.setTextColor(getResources().getColor(R.color.black));
                    text_wuzuo.setTextColor(getResources().getColor(R.color.black));
                    text_yinzuo.setTextColor(getResources().getColor(R.color.black));
                    text_ruanzuo.setTextColor(getResources().getColor(R.color.black));
                    text_yinwo.setTextColor(getResources().getColor(R.color.black));
                    text_ruanwo.setTextColor(getResources().getColor(R.color.black));
                    text_gaojiruanwo.setTextColor(getResources().getColor(R.color.black));
                    text_dongwo.setTextColor(getResources().getColor(R.color.black));
                    ticket_type = "一等座";
                    czh_tv12.setText((type2_price+"元").trim());
                    czh_tv15.setText((type2_num+"张").trim());
                    price = type2_price;
                    type_num = "2";
                }
            });
            text_tedengzhuo.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    text_erdengzhuo.setBackgroundResource(R.drawable.select1);
                    text_yidengozhuo.setBackgroundResource(R.drawable.select1);
                    text_tedengzhuo.setBackgroundResource(R.drawable.select);
                    text_wuzuo.setBackgroundResource(R.drawable.select1);
                    text_yinzuo.setBackgroundResource(R.drawable.select1);
                    text_ruanzuo.setBackgroundResource(R.drawable.select1);
                    text_yinwo.setBackgroundResource(R.drawable.select1);
                    text_ruanwo.setBackgroundResource(R.drawable.select1);
                    text_gaojiruanwo.setBackgroundResource(R.drawable.select1);
                    text_dongwo.setBackgroundResource(R.drawable.select1);
                    text_erdengzhuo.setTextColor(getResources().getColor(R.color.black));
                    text_yidengozhuo.setTextColor(getResources().getColor(R.color.black));
                    text_tedengzhuo.setTextColor(getResources().getColor(R.color.white));
                    text_wuzuo.setTextColor(getResources().getColor(R.color.black));
                    text_yinzuo.setTextColor(getResources().getColor(R.color.black));
                    text_ruanzuo.setTextColor(getResources().getColor(R.color.black));
                    text_yinwo.setTextColor(getResources().getColor(R.color.black));
                    text_ruanwo.setTextColor(getResources().getColor(R.color.black));
                    text_gaojiruanwo.setTextColor(getResources().getColor(R.color.black));
                    text_dongwo.setTextColor(getResources().getColor(R.color.black));
                    ticket_type = "特等座";
                    czh_tv12.setText((type3_price+"元").trim());
                    czh_tv15.setText((type3_num+"张").trim());
                    price = type3_price;
                    type_num = "3";
                }
            });
            text_wuzuo.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    text_erdengzhuo.setBackgroundResource(R.drawable.select1);
                    text_yidengozhuo.setBackgroundResource(R.drawable.select1);
                    text_tedengzhuo.setBackgroundResource(R.drawable.select1);
                    text_wuzuo.setBackgroundResource(R.drawable.select);
                    text_yinzuo.setBackgroundResource(R.drawable.select1);
                    text_ruanzuo.setBackgroundResource(R.drawable.select1);
                    text_yinwo.setBackgroundResource(R.drawable.select1);
                    text_ruanwo.setBackgroundResource(R.drawable.select1);
                    text_gaojiruanwo.setBackgroundResource(R.drawable.select1);
                    text_dongwo.setBackgroundResource(R.drawable.select1);
                    text_erdengzhuo.setTextColor(getResources().getColor(R.color.black));
                    text_yidengozhuo.setTextColor(getResources().getColor(R.color.black));
                    text_tedengzhuo.setTextColor(getResources().getColor(R.color.black));
                    text_wuzuo.setTextColor(getResources().getColor(R.color.white));
                    text_yinzuo.setTextColor(getResources().getColor(R.color.black));
                    text_ruanzuo.setTextColor(getResources().getColor(R.color.black));
                    text_yinwo.setTextColor(getResources().getColor(R.color.black));
                    text_ruanwo.setTextColor(getResources().getColor(R.color.black));
                    text_gaojiruanwo.setTextColor(getResources().getColor(R.color.black));
                    text_dongwo.setTextColor(getResources().getColor(R.color.black));
                    ticket_type = "无座";
                    czh_tv12.setText((type1_price+"元").trim());
                    czh_tv15.setText((type1_num+"张").trim());
                    price = type1_price;
                    type_num = "1";
                }
            });
        }

        Button change_ticket = (Button)findViewById(R.id.bt_buy_ticket); //提交

        czh_tv1.setText(startPlace.trim());
        czh_tv4.setText(endPlace.trim());
        czh_tv2.setText(startTime.trim());
        czh_tv16.setText(endTime.trim());
        czh_tv14.setText(vehicleNum.trim());
        czh_tv13.setText(date.trim());

        change_ticket.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_DOWN) {
                    v.setBackgroundDrawable(getResources().getDrawable(R.drawable.pswshape2));
                } else if (event.getAction() == MotionEvent.ACTION_UP) {
                    v.setBackgroundDrawable(getResources().getDrawable(R.drawable.pswshape));

                    try {
                        if (ticket_type != null) {
                            //改签第二部，退票
                            Socket.connector.send(Socket.connector.package_data(Socket.connector.TICKET_CMD_TYPE,
                                    Socket.connector.RETURN_TICKET, "00",
                                    id + CommunicationData.empty +
                                            old_vehicleNum.trim() + CommunicationData.empty));
                            Socket.connector.recv_ack();
                            if (CommunicationData.ack == "01") {
                                Socket.connector.recv_ack();
                                if (CommunicationData.ack == Socket.connector.RETURN_TICKET_SUCCESS_ACK) {
                                    //改签第三部：买票
                                    Socket.connector.send(Socket.connector.package_data(Socket.connector.TICKET_CMD_TYPE,
                                            Socket.connector.BUY_TICKET, "00",
                                            id.trim() + CommunicationData.empty +
                                                    startPlace.trim() + CommunicationData.empty +
                                                    endPlace.trim() + CommunicationData.empty +
                                                    startTime.trim() + CommunicationData.empty +
                                                    endTime.trim() + CommunicationData.empty +
                                                    vehicleNum.trim() + CommunicationData.empty +
                                                    price.trim() + CommunicationData.empty +
                                                    date.trim() + CommunicationData.empty +
                                                    ticket_type.trim() + CommunicationData.empty +
                                                    type_num.trim() + CommunicationData.empty));
                                    Socket.connector.recv_ack();
                                    if (CommunicationData.ack == "01") {
                                        Socket.connector.recv_ack();
                                        if (CommunicationData.ack == Socket.connector.BUY_TICKET_SUCCESS_ACK) {
                                            Message m = new Message();
                                            m.what = 1;
                                            myHandler.sendMessage(m);
                                        } else {
                                            Message m = new Message();
                                            m.what = 2;
                                            myHandler.sendMessage(m);
                                        }
                                    }
                                } else {
                                    Message m = new Message();
                                    m.what = 2;
                                    myHandler.sendMessage(m);
                                }
                            }

                            //改签第二部：买票
                            /*Socket.connector.send(Socket.connector.package_data(Socket.connector.TICKET_CMD_TYPE,
                                    Socket.connector.BUY_TICKET, "00",
                                    id.trim() + CommunicationData.empty +
                                            startPlace.trim() + CommunicationData.empty +
                                            endPlace.trim() + CommunicationData.empty +
                                            startTime.trim() + CommunicationData.empty +
                                            endTime.trim() + CommunicationData.empty +
                                            vehicleNum.trim() + CommunicationData.empty +
                                            price.trim() + CommunicationData.empty +
                                            date.trim() + CommunicationData.empty +
                                            ticket_type.trim() + CommunicationData.empty +
                                            type_num.trim() + CommunicationData.empty));
                            Socket.connector.recv_ack();
                            if (CommunicationData.ack == "01") {
                                Socket.connector.recv_ack();
                                if (CommunicationData.ack == Socket.connector.BUY_TICKET_SUCCESS_ACK) {
                                    //改签第三部，退票
                                    Socket.connector.send(Socket.connector.package_data(Socket.connector.TICKET_CMD_TYPE,
                                            Socket.connector.RETURN_TICKET, "00",
                                            id + CommunicationData.empty +
                                                    old_vehicleNum.trim() + CommunicationData.empty));
                                    Socket.connector.recv_ack();
                                    if (CommunicationData.ack == "01") {
                                        Socket.connector.recv_ack();
                                        if (CommunicationData.ack == Socket.connector.RETURN_TICKET_SUCCESS_ACK) {
                                            Message m = new Message();
                                            m.what = 1;
                                            myHandler.sendMessage(m);
                                        } else {
                                            Message m = new Message();
                                            m.what = 2;
                                            myHandler.sendMessage(m);
                                        }
                                    }
                                }
                            }*/
                        } else {
                            Message m = new Message();
                            m.what = 3;
                            myHandler.sendMessage(m);
                        }
                    } catch (IOException e) {
                    }
                }
                return true;
            }
        });
    }
}
